﻿@model Core_Ticket
@{
    ViewBag.ParentUrl = "/Ticket/Index";
    ViewBag.Title = "单证发放";
}
@section header{
    <style>
        .profile-info-name {
            width: auto;
        }
    </style>
}
@section breadcrumb
{
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-home home-icon"></i>
            <a href="/">首页</a>
        </li>
        <li class="active">@ViewBag.Title</li>
    </ul><!-- .breadcrumb -->
}

<div class="row">
    <div class="col-xs-12">

        <div class="widget-box">
            <div class="widget-header widget-header-flat">
                <h4 class="smaller">
                    <i class="icon-search"></i>
                    @ViewBag.Title
                </h4>
            </div>

            <div class="widget-body">
                <div class="widget-main">
                    <div class="profile-user-info profile-user-info-striped">
                        <div class="profile-info-row">
                            <div class="profile-info-name"> 产品名称： </div>

                            <div class="profile-info-value">
                                @Model.T_ProductName
                                @Html.HiddenFor(o => o.T_Id)
                                @Html.HiddenFor(o => o.T_Memo)
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name"> 单证名称： </div>

                            <div class="profile-info-value">
                                @Model.T_Name
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name"> 单证起始号： </div>

                            <div class="profile-info-value">
                                @Html.TextBoxFor(o => o.T_CurrentNo, new { @class = "input-large", type = "number", placeholder = "单证起始号" })
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name"> 单证结束号： </div>

                            <div class="profile-info-value">
                                @Html.TextBoxFor(o => o.T_ENo, new { @class = "input-large", type = "number", placeholder = "单证结束号" })
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name"> 发放数量： </div>

                            <div class="profile-info-value">
                                @Html.TextBoxFor(o => o.T_RemainCount, new { @class = "input-large", type = "number", placeholder = "发放数量" })
                                <code>总数:@Model.T_Count</code>
                            </div>
                        </div>


                        <div class="profile-info-row">
                            <div class="profile-info-name"> 发放用户： </div>

                            <div class="profile-info-value">
                                @Html.DropDownList("user", (IEnumerable<SelectListItem>)TempData["UserList"], new { @class = "col-xs-12 col-sm-3", style = "width: 360px;" })

                            </div>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="button" id="btnSubmit">
                                <i class="ace-icon fa fa-check bigger-110"></i>
                                修改并保存
                            </button>

                            &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="ace-icon fa fa-undo bigger-110"></i>
                                重置
                            </button>
                        </div>
                    </div>
                    <div class="hr hr-24"></div>
                </div>
            </div>
        </div>

    </div>
</div>

@section footer{
    <script src="/assets/js/bootbox.min.js"></script>
    <script>
        $(function() {
            $('#btnSubmit').on('click', function() {


                var count = $('#T_RemainCount').val();
                if (count < 1) {
                    alert("发放数量错误");
                    return false;
                }
                var text = $("#user").find("option:selected").text();
                var val = $("#user").val();
                $.post('/Ticket/Send', { id: '@Model.T_Id', memo: '@Model.T_Memo', count: count,uname:text,uid:val }, function(o) {
                    //alert(o.Msg);
                    if ('ok' == o) {
                        bootbox.alert("操作成功！", function() {
                            //window.location.reload();
                            location.reload();
                        });
                    } else {
                        bootbox.alert("操作有误！");
                    }
                });
            });
        });
    </script>
}